/**************************************************************************//**
  \file pingpong.h

  \brief Ping-pong sample application header file.

  \author
    Atmel Corporation: http://www.atmel.com \n
    Support email: avr@atmel.com

  Copyright (c) 2008-2012, Atmel Corporation. All rights reserved.
  Licensed under Atmel's Limited License Agreement (BitCloudTM).

  \internal
    History:
******************************************************************************/
#ifndef _PINGPONG_H
#define _PINGPONG_H

/******************************************************************************
                    Includes section
******************************************************************************/
#include "sliders.h"
#include "leds.h"
#include <usart.h>
#if APP_INTERFACE == APP_INTERFACE_USBFIFO
  #include <usbFifoUsart.h>
#endif // APP_INTERFACE_USBFIFO

/******************************************************************************
                    Defines section
******************************************************************************/
#if APP_INTERFACE == APP_INTERFACE_USART
  #define USART_Open HAL_OpenUsart
  #define USART_Write HAL_WriteUsart
  #define USART_Close HAL_CloseUsart
#elif APP_INTERFACE == APP_INTERFACE_USBFIFO
  #define USART_Open  USBFIFO_OpenUsart
  #define USART_Close USBFIFO_CloseUsart
  #define USART_Write USBFIFO_WriteUsart
#else
  #define USART_Open(d)
  #define USART_Write(d,b,s)
  #define USART_Close(d)
#endif

#define NETWORK_LED LED_GREEN
#define DATA_LED    LED_YELLOW
#define BIND_LED    LED_RED

#ifndef APP_TIMER_STARTING_NETWORK
  #define APP_TIMER_STARTING_NETWORK 500 // LED blinking interval during network start, ms
#endif

#ifndef APP_TIMER_FW_DELAY
  #define APP_TIMER_FW_DELAY 1000 // Packet forwarding delay, ms
#endif

#define APP_PAYLOAD_SIZE 1 // Appliation payload size in bytes

#define PINGPONG_ENDPOINT   1      // End-point for transmission and receive.

#define START_CLUSTER  0x2000
#define PINGPONG_PROFILE 0x3000
#define BROADCAST_SHORT_ADDRESS 0xffff
#define SLIDER_1_MASK 0x01
#define SLIDER_2_MASK 0x02
#define SLIDER_3_MASK 0x04
#define SLIDERS_MASK (SLIDER_1_MASK | SLIDER_2_MASK | SLIDER_3_MASK)
#define ADDRESS_SLIDERS_MASK (SLIDER_1_MASK | SLIDER_2_MASK)


typedef enum         // Type specifing application state
{
  APP_INITING_STATE,
  APP_AWAITING_NETWORK_START_STATE,
  APP_NETWORK_STARTING_STATE,
#if APP_USE_BINDING == 1
  APP_INITIATE_BINDING_STATE,
  APP_BINDING_IN_PROGRESS_STATE,
#endif // APP_USE_BINDING
  APP_IN_NETWORK_STATE,
  APP_NO_NETWORK_STATE,
  APP_NETWORK_DATA_SENDING_STATE,
  APP_WAITING_CONFIRM_STATE,
#if TEST_NETWORK == 1
  APP_SENDING_HEARTBEAT
#endif // TEST_NETWORK
} AppState_t;

#endif // _PINGPONG_H

// eof pingpong.h
